package com.ruoyi.love.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.love.domain.Love;
import com.ruoyi.love.service.ILoveService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 喜爱表Controller
 * 
 * @author ruoyi
 * @date 2025-03-04
 */
@RestController
@RequestMapping("/love/love")
public class LoveController extends BaseController
{
    @Autowired
    private ILoveService loveService;

    /**
     * 查询喜爱表列表
     */
    @PreAuthorize("@ss.hasPermi('love:love:list')")
    @GetMapping("/list")
    public TableDataInfo list(Love love)
    {
        startPage();
        List<Love> list = loveService.selectLoveList(love);
        return getDataTable(list);
    }

    /**
     * 导出喜爱表列表
     */
    @PreAuthorize("@ss.hasPermi('love:love:export')")
    @Log(title = "喜爱表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Love love)
    {
        List<Love> list = loveService.selectLoveList(love);
        ExcelUtil<Love> util = new ExcelUtil<Love>(Love.class);
        util.exportExcel(response, list, "喜爱表数据");
    }

    /**
     * 获取喜爱表详细信息
     */
    @PreAuthorize("@ss.hasPermi('love:love:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(loveService.selectLoveById(id));
    }

    /**
     * 新增喜爱表
     */
    @PreAuthorize("@ss.hasPermi('love:love:add')")
    @Log(title = "喜爱表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Love love)
    {
        return toAjax(loveService.insertLove(love));
    }

    /**
     * 修改喜爱表
     */
    @PreAuthorize("@ss.hasPermi('love:love:edit')")
    @Log(title = "喜爱表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Love love)
    {
        return toAjax(loveService.updateLove(love));
    }

    /**
     * 删除喜爱表
     */
    @PreAuthorize("@ss.hasPermi('love:love:remove')")
    @Log(title = "喜爱表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(loveService.deleteLoveByIds(ids));
    }
}
